<template>
    <div>
        <h3>{{this.$store.getters.showNum}}</h3>
        <button @click="handle1">+1</button>
        <button @click="handle2">+N</button>
        <button @click="handle3">+1 Async</button>
        <button @click="handle4">+N Async</button>
    </div>
</template>

<script>

export default {
    data(){
        return {}
    },
    methods:{
        //commit的作用就是调用某个mutation函数
        handle1(){
            this.$store.commit('add')
        },
        handle2(){
            this.$store.commit('addN',3)
        },
        //异步地让count+1
        handle3(){
            this.$store.dispatch('addAsync')
        },
        handle4(){
            this.$store.dispatch('addnAsync',5)
        }
    }
}

</script>
